﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;

namespace CoreModule.Converters
{
    /// <summary>
    /// 测量值 to 颜色
    /// </summary>
    public class MeasurementValueToSolidColorBrushConverter : IValueConverter
    {
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

                var measurementValue = (double)value;
                var bloodGlucosePeriod = (CoreModule.BloodGlucosePeriod)parameter;
               ///先 转换 成状态
                var bloodGlucoseStatus = Extension.GetBloodGlucoseStatus(bloodGlucosePeriod, measurementValue);
               ///取对应颜色
                var color= Extension.GetBloodGlucoseStatusColor(bloodGlucoseStatus);
                return new SolidColorBrush(color);
 
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
